// 定义vue公共元素组件
Vue.component("common",{
    // `` 反引号 数字键1 左边的键
   template: `
   <div>
    <div id="header" class="wrap">
\t<img src="images/logo.gif" />
</div>
    <div id="navbar" class="wrap">
\t<div class="profile">
\t\t<span v-if="myinfo">
        您好，{{ myinfo.uname }}
        <a href="/demovote/user/logout">退出</a>
    </span>
    <span v-else>
        <a href="/login.html">登录</a>
        <a href="/register.html">注册</a>
    </span>
\t\t<span class="return"><a href="index.html">返回列表</a></span>
\t\t<span class="addnew"><a href="add.html">添加新投票</a></span>
\t</div>
\t<div class="search">
\t\t<form method="post" action="#">
\t\t\t<input type="text" name="keywords" class="input-text" value=""/><input type="submit" name="submit" class="input-button" value="" />
\t\t</form>
\t</div>
</div>
    <slot></slot>
    <div id="footer" class="wrap">
    \t源辰信息 &copy; 版权所有
    </div>
   </div>
   `,
   data(){
      return { myinfo:null };
   },
   // 钩子函数（事件函数）
   created(){
      axios.get("/demovote/user/myinfo").then(res=>{
         if(res.data.code==1){
            this.myinfo = res.data.data
         } else {
            this.myinfo = null;
         }
      })
   }

});